//
//  HHProject.m/Users/ahuan/Documents/HHgitosc/HHgitosc/HHgitosc/Classes/Project-项目/Models/HHProject.m
//  osc
//
//  Created by hjl on 16/3/21.
//  Copyright © 2016年 hjl. All rights reserved.
//

#import "HHProject.h"
#import <MJExtension.h>
#import "HHUser.h"
#import "HHNamespace.h"

@implementation HHProject

+ (NSDictionary *)mj_replacedKeyFromPropertyName{
    return @{
             @"HHpublic" : @"public",
             @"projectId" : @"id",
             @"HHdescription" : @"description",
             
             
    };
}
/**
 *  数组中需要转换的模型类
 *
 *  @return 字典中的key是数组属性名，value是数组中存放模型的Class（Class类型或者NSString类型）
 */
+ (NSDictionary *)mj_objectClassInArray{
    return @{
             @"namespace" : [HHNamespace class],
             @"owner" : [HHUser class],
             };
}


// 计算cell的高度
- (CGFloat)cellHeight{
    if(!_cellHeight){
        CGFloat margin = 6;
        CGFloat nameLabelH = 15;
        CGFloat footViewH = 25;
        CGFloat headViewW = 35;
        
        _cellHeight = margin + nameLabelH + margin;
        
        if(self.HHdescription){
            CGSize maxSize = CGSizeMake([UIScreen mainScreen].bounds.size.width - headViewW - 5 * margin, MAXFLOAT);
            
            CGFloat cententLableH = [self.HHdescription boundingRectWithSize:maxSize options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName : [UIFont systemFontOfSize:14]} context:nil].size.height;
            if (cententLableH > 68) {
                cententLableH = 68;
            }

            _cellHeight += cententLableH + 10;
        }
        _cellHeight += footViewH;
    }
    return _cellHeight;
}

- (CGSize)headerViewSize{
    CGFloat headerViewSizeW = [UIScreen mainScreen].bounds.size.width;
    
    CGFloat margin = 8;
    CGFloat bigmargin = 16;
    CGFloat IconViewH = 35;
    CGFloat nameLabelH = 21;
    CGFloat lineH = 1;
    CGFloat bottomViewH = 80;
    CGFloat middleViewH = 60;
    
    CGSize maxSize = CGSizeMake([UIScreen mainScreen].bounds.size.width - 2 * margin, MAXFLOAT);
    
    CGFloat cententLableH = [self.HHdescription boundingRectWithSize:maxSize options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName : [UIFont systemFontOfSize:14]} context:nil].size.height;
    
    CGFloat headerViewSizeH = margin + IconViewH + margin + nameLabelH + margin + lineH + margin + cententLableH + margin + middleViewH + bigmargin + bottomViewH + 30;
    //NSLog(@"%@", cententLableH);
    //NSLog(@"%@", headerViewSizeH);
    
    _headerViewSize = CGSizeMake(headerViewSizeW, headerViewSizeH);
    
    
    return _headerViewSize;
}


@end
